Function Reference

_AD_IsAccountExpired

Returns 1 if the account (user, computer) has expired.

#Include <AD.au3>
_AD_IsAccountExpired([$sObject = @Username])

 

Parameters

$sObject Optional: Account (User, computer) to check (default = @Username). Can be specified as Fully Qualified Domain Name (FQDN) or sAMAccountName

 

Return Value

Success: 1, The specified account has expired
Failure: 0, sets @error to:
    0 - Account has not expired
    1 - $sObject could not be found
    2 - An error occurred when accessing property AccountExpirationDate. @extended is set to the error returned by LDAP

 

Remarks

None.

 

Related

_AD_GetAccountsExpired, _AD_SetAccountExpire

 

See Also

http://www.rlmueller.net/AccountExpires.htm

 

Example


#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include <AD.au3>

; Open Connection to the Active Directory
_AD_Open()
If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Example 1
; Checks if the current user account is expired.
; *****************************************************************************
Global $iResult = _AD_IsAccountExpired()
If @error Then
    MsgBox(16, "Active Directory Example Skript", "Function _AD_IsAccountExpired encountered a problem. @error = " & @error & ", @extended = " & @extended)
ElseIf $iResult = 1 Then
    MsgBox(64, "Active Directory Functions", "User account '" & @UserName & "' has expired")
Else
    MsgBox(64, "Active Directory Functions", "User account '" & @UserName & "' has not expired")
EndIf

; *****************************************************************************
; Example 2
; Checks if the current computer account is expired.
; *****************************************************************************
$iResult = _AD_IsAccountExpired(@ComputerName & "$")
If @error Then
    MsgBox(16, "Active Directory Example Skript", "Function _AD_IsAccountExpired encountered a problem. @error = " & @error & ", @extended = " & @extended)
ElseIf $iResult = 1 Then
    MsgBox(64, "Active Directory Functions", "Computer account '" & @ComputerName & "$" & "' has expired")
Else
    MsgBox(64, "Active Directory Functions", "Computer account '" & @ComputerName & "$" & "' has not expired")
EndIf

; Close Connection to the Active Directory
_AD_Close()